BattlePanel = {};
local this = BattlePanel;

local gameObject;
local transform;
local behaviour;

function BattlePanel.New()
	panelMgr:CreatePanel("Battle", nil);
end

function BattlePanel.Awake(go)
	log("BattlePanel.Awake");
	gameObject = go;
	transform = go.transform;
	behaviour=go:GetComponent('LuaBehaviour');

	this.hpText = transform:Find("HpText"):GetComponent('Text');
	this.scoreText = transform:Find("ScoreText"):GetComponent('Text');
	this.settingBtn=transform:Find("SettingBtn").gameObject;
	
	behaviour:AddClick(this.settingBtn,this.OnSettingClick);

	Event.AddListener("HpChange", this.SetHp);
	Event.AddListener("ScoreChange", this.SetScore);
end

function BattlePanel.SetHp(val)
	this.hpText.text = "Hp:" .. val;
end

function BattlePanel.SetScore(val)
	this.scoreText.text = "Score:" .. val;
end

function BattlePanel.OnSettingClick()
	SettingPanel.New();
end

function BattlePanel.OnDestroy()
	Event.RemoveListener("HpChange", this.SetHp);
	Event.RemoveListener("ScoreChange", this.SetScore);
end 